home *** CD-ROM | disk | FTP | other *** search
/ HyperLib 1997 Winter - Disc 1 / HYPERLIB-1997-Winter-CD1.ISO.7z / HYPERLIB-1997-Winter-CD1.ISO / オンラインウェア / COM / LineShare 3.3.1 folder.sit / LineShare 3.3.1 folder / LineShare 3.3.1 / LineShare Scripts / Hayes Optima Fax1&ARA&Data < prev    next >
Text File  |  1994-10-13  |  8KB  |  416 lines

  1. ! Version 3.0
  2. !
  3. !$ Use this script with Hayes Optima data/fax modems.
  4. !$ Supports: fax, ARA and regular data incoming calls.
  5. !
  6. !$ A cable for hardware handshaking is required
  7.  
  8. ^2 Speaker On:        = Enum("Never" = "0","During Connect" = "1", "Always"="2") "1"
  9. ^3 Speaker Volume:       = Enum("Low"="1","Medium"="2","High"="3") "2"
  10. ^4 Answer On:         = Enum("1 Ring"="1","2 Rings"="2","3 Rings"="3","5 Rings"="5","7 Rings"="7") "2"
  11. ^5 Port Speed:        = Enum("9600","19200","38400","57600") "19200"
  12. ^6 Handshake wires:   = Bool("Both"="&D0","CTS only"="&D2") "&D2"
  13. ^7 Error Correction:   = Bool("Disabled"="&Q6","Enabled"="&Q5") "&Q6"
  14. ! ------------------------------------------
  15. ! Resetting the modem:
  16. ! ------------------------------------------
  17. @Hangup
  18.   SetTries 2
  19.   Flush
  20.   HsReset 0,0,17,19,0,0
  21. !
  22. ! Try to catch the "OK" answer, use the Escape seq and DTR transitions
  23. ! to enter the command mode
  24. !
  25. @Label 1
  26.   matchclr
  27.   matchstr 1 2 "OK¥r¥n"
  28.   write "ATH0&F¥r"
  29.   matchread 20
  30.   ChrDelay 1
  31.   Write "+++"
  32.   ChrDelay 0
  33.   pause 10
  34.   DtrClear
  35.   SBreak
  36.   DtrSet
  37. !
  38.   DecTries
  39.   IfTries 0 1
  40. !
  41. ! OSErr -6019 "Modem error - the modem is not responding"
  42. !
  43.   exit -6019
  44. @Label 2
  45.   write "AT+FCLASS=0¥r"
  46.   Jsr 100
  47.   write "AT+FAE=0¥r"
  48.   Jsr 100
  49.   exit 0
  50.  
  51. ! ------------------------------------------
  52. !    Receiving incoming calls
  53. ! ------------------------------------------
  54. @ANSWER
  55. !
  56. ! Set the modem preferred speed first
  57. !
  58.   SerReset Val("^5"),0,8,1
  59.   Jsr 80
  60.  
  61. @Label 10
  62. !
  63. ! Set the common options
  64.   Jsr 70
  65. !
  66. ! Set the communication options:
  67. ! ・ &Q6: Normal connection (for ARA)
  68. ! ・ &K3: HW flow control   (for ARA, Fax should not use a handshake on receiving)
  69. ! ・ W2:  report connection speed
  70. !
  71.   Write "AT^7&K3W2¥r"
  72.   Jsr 100
  73. !
  74. ! Set Fax mode
  75. !
  76.   Write "AT+FCLASS=1¥r"
  77.   Jsr 100
  78.   Write "AT+FAE=1¥r"
  79.   Jsr 100
  80. !
  81. ! It's for Rockwell ONLY! Set FCLASS to 0 again - otherwise,
  82. ! it cannot accept data calls
  83. !
  84. !  Write "AT+FCLASS=0¥r"
  85. !  Jsr 100
  86. !
  87. ! Tell the modem to determine the type of the incoming call
  88. ! Fetch the tube after ^4 rings
  89. !
  90.   Write "ATS0=^4V0¥r"
  91.   Jsr 110
  92. !
  93. ! Everything is ready - let's sit and wait for a call
  94. ! We'll wait for 2 minutes, then reinitiate the modem
  95. !
  96.   Note "Waiting for a fax/ARA/data callノ"
  97.   MatchClr
  98.   matchstr 02 40 "10¥r"
  99.   MatchStr 03 41 "11¥r"
  100.   MatchStr 04 42 "24¥r"
  101.   MatchStr 05 43 "12¥r"
  102.   MatchStr 06 44 "25¥r"
  103.   MatchStr 07 45 "13¥r"
  104.   MatchStr 08 46 "26¥r"
  105.   MatchStr 09 47 "14¥r"
  106.   MatchStr 10 48 "60¥r"
  107.   MatchStr 11 49 "29¥r"
  108.   MatchStr 12 50 "34¥r"
  109.   MatchStr 13 51 "15¥r"
  110.  
  111.   MatchStr 15 19 "33¥r"
  112.   matchstr 16 18 "2¥r"
  113.   matchstr 17 57 "1¥r"
  114.   matchstr 18 17 "3¥r"
  115.   matchstr 19 17 "8¥r"
  116.   matchstr 20 17 "7¥r"
  117. @Label 16
  118.   Matchread 1200
  119. @Label 17
  120.   Note "Tuning againノ"
  121.   Write "ATV1¥r"
  122.   Jsr 100
  123.   Jump 10
  124. @Label 18
  125.   Note "Ringノ"
  126.   jump 16
  127. @Label 19
  128. ! SetSpeed 19200
  129.   Note "Fax tones detectedノ"
  130.   Jump 16
  131.  
  132. !
  133. ! Data connection has been established (we read "CONNECT")
  134. ! Put the "CONNECT" back to the buffer and attach the "Data" subPort
  135. ! if it was an incoming call, put the "RING" before the "CONNECT"
  136. !
  137. @Label 20
  138.   IfOpen "Data" 21
  139.   Jump 30
  140. @Label 21
  141.   IfOpen "ARA" 22
  142.   Jump 35
  143. @Label 22
  144.   Note "Waiting for an ARA frame"
  145.   MatchClr
  146.   MatchStr 1 23 "^$¥r"
  147.   MatchStr 2 28 "¥08¥01¥03¥14¥04¥03¥00¥08¥250¥16¥03"
  148.   MatchStr 3 29 "¥01¥27¥02¥29¥01¥02¥01¥06"
  149.   MatchRead 60
  150.   Jump 24
  151. @Label 23
  152.   QueueInput "^$¥r"
  153. @Label 24
  154.   Note "Non-ARA call"
  155.   Jump 35
  156.  
  157. @Label 28
  158.   Note "ARA 1.0 call"
  159.   Jump 30
  160. @Label 29
  161.   Note "ARA 2.0 call"
  162.   Jump 30
  163.  
  164. @Label 30
  165.   QueueInput "¥r¥nCARRIER ^B¥r¥n"  
  166.   QueueInput "¥r¥nRING¥r¥n"
  167.   Attach "ARA" (DTR)
  168.  
  169. @Label 35
  170.   GetSReg C "DATA" 4
  171.   QueueInput "¥r^CCONNECT ^B¥r^C"
  172.   ifOriginate 36
  173.   QueueInput "¥r^CRING¥r^C"
  174. @Label 36
  175.   Attach "Data" (DTR,Escape,Break)
  176.  
  177.  
  178. !
  179. ! Converting numeric responses into the verbal
  180. !
  181. @Label 40
  182.   SetVar B "2400"
  183.   Jump 20
  184. @Label 41
  185.   SetVar B "4800"
  186.   Jump 20
  187. @Label 42
  188.   SetVar B "7200"
  189.   Jump 20
  190. @Label 43
  191.   SetVar B "9600"
  192.   Jump 20
  193. @Label 44
  194.   SetVar B "12000"
  195.   Jump 20
  196. @Label 45
  197.   SetVar B "14400"
  198.   Jump 20
  199. @Label 46
  200.   SetVar B "16800"
  201.   Jump 20
  202. @Label 47
  203.   SetVar B "19200"
  204.   Jump 20
  205. @Label 48
  206.   SetVar B "21600"
  207.   Jump 20
  208. @Label 49
  209.   SetVar B "24000"
  210.   Jump 20
  211. @Label 50
  212.   SetVar B "26400"
  213.   Jump 20
  214. @Label 51
  215.   SetVar B "28800"
  216.   Jump 20
  217.  
  218. ! ------------------------------------------
  219. ! Originating a call through the "ARA" subport
  220. ! ------------------------------------------
  221. @ORIGINATE "ARA"
  222.   SerReset Val("^5"),0,8,1
  223.   Jsr 80
  224. !
  225. ! Set the common options
  226. !
  227.   Jsr 70
  228. !
  229. ! Set the Data mode:
  230. ! ・ &Q5/6:Normal connection
  231. ! ・ &K3: HW Handshake
  232. ! ・ハS7:  time-out (90 sec) for long-distance call (if you use them)
  233. ! ・ W2:  report connection rate
  234. !
  235.   Write "AT^7&K3S7=90W2¥r"
  236.   Jsr 100
  237. !
  238. ! Emit the ARA script commands ("Xnn")
  239.   Jsr 60
  240. !
  241. ! Prepare to receive all error result codes, dial the number
  242. !
  243.   Jsr 90
  244.   MatchStr 1 55 "¥r¥nCONNECT "
  245.   MatchRead 1000
  246.   Write "¥r"
  247.   Exit -6019
  248. @Label 55
  249.   QueueInput "¥r¥nCARRIER "
  250.   Attach "ARA" (DTR)
  251.  
  252. ! ------------------------------------------
  253. ! Originating a call through the "DATA" subport
  254. ! ------------------------------------------
  255. @ORIGINATE "Data"
  256.   SerReset Val("^5"),0,8,1
  257.   Jsr 80
  258. !
  259. ! Set the common options
  260. !
  261.   Jsr 70
  262. !
  263. ! Set the Data mode:
  264. ! ・ &K3: HW Handshake
  265. ! ・ハS7:  time-out (90 sec) for long-distance call (if you use them)
  266. !
  267.   Write "AT^7&K3S7=90¥r"
  268.   Jsr 100
  269. !
  270. ! Emit the Data commands
  271.   Jsr 60
  272. !
  273. ! Prepare to receive all error result codes, dial the number
  274. !
  275.   Jsr 90
  276.   MatchStr 1 56 "¥r¥nCONNECT "
  277.   MatchRead 1000
  278.   Write "¥r"
  279.   Exit -6019
  280. @Label 56
  281.   QueueInput "¥r¥nCONNECT "
  282.   Attach "Data" (DTR,Escape,Break)
  283.  
  284. ! ------------------------------------------
  285. ! Originating a call through the "Fax" subPort
  286. ! ------------------------------------------
  287. @ORIGINATE "Fax"
  288. !
  289. ! Set the "Fax" speed
  290. !
  291.   SerReset 19200,0,8,1
  292.   Jsr 80
  293. !
  294. ! Set the common options
  295. !
  296.   Jsr 70
  297. !
  298. ! Set the Fax mode
  299. ! &K4: Xon/Xoff handshake
  300. ! &S0: DSR always on (see above)
  301. !
  302.   Write "AT&S0&K4+FCLASS=1¥r"
  303.   Jsr 100
  304. !
  305. ! Now emit all commands that the application has sent to that port,
  306. ! except "FCLASS", etc
  307. !
  308.   EmitClear "+FCLASS","V","E"
  309.   Jsr 60
  310.   Write "ATV0¥r"
  311.   Jsr 110
  312. !
  313. ! Prepare to receive all error result codes, dial the number
  314. !
  315.   MatchClr
  316.   MatchStr 01 57 "1¥r"
  317.   MatchStr 13 93 "3¥r"
  318.   MatchStr 14 94 "8¥r"
  319.   MatchStr 15 92 "7¥r"
  320.   Write "ATD^1¥r"
  321.   HsReset *
  322.   MatchRead 900
  323.   Write "¥r"
  324.   Exit -6019
  325.  
  326. !
  327. ! Fax connection has been established (we read "FAX")
  328. ! Put the +FCON back to the buffer,
  329. ! if it was an incoming call, put the "RING" before the "+FCON"
  330. ! Attach the "Fax" subPort
  331. !
  332. @Label 57
  333.   QueueInput "1¥r"
  334. !  SetSpeed 19200
  335.   ifOriginate 59
  336. !@Label 58
  337.   QueueInput "2¥r2¥r"
  338. @Label 59
  339.   Attach "Fax" (Reset(2400),IdleLimit=30)
  340.  
  341. !
  342. ! This section emits all modem commands sent from the client application
  343. ! For each set of commands the "OK" answer is awaited
  344. !
  345. @Label 60
  346.   EmitStart
  347. @Label 61
  348.   EmitCommand 62
  349.   Jsr 100
  350.   Jump 61
  351. @Label 62
  352.   return
  353. !
  354. ! This section initiates the modem before ANSWER and ORIGINATEs:
  355. ! extended responses + connect at the highest rate + speaker control +
  356. ! reset on Dtr drop + DCD valid
  357. ! Verbal responses mode, no echo 
  358. !
  359. @Label 70
  360.   Write "ATX4N1M^2L^3^6&C1V1E0¥r"
  361.   Jsr 100
  362.   return 
  363.  
  364. !
  365. ! This section syncronize the modem after the serial port speed switching
  366. !
  367. @Label 80
  368.   ChrDelay 1
  369.   Write "AT¥r"
  370.   ChrDelay 0
  371.   Jsr 100
  372.   return
  373. !
  374. ! Prepare to receive error result codes, send the dialing command and
  375. ! set the user's handshake mode
  376. !
  377. @Label 90
  378.   MatchClr
  379.   MatchStr 2 91 "NO DIALTONE¥r¥n"
  380.   MatchStr 3 92 "BUSY¥r¥n"
  381.   MatchStr 4 93 "NO CARRIER¥r¥n"
  382.   MatchStr 5 94 "NO ANSWER¥r¥n"
  383.   Write "ATD^1¥r"
  384.   HsReset *
  385.   return
  386. @Label 91
  387.   exit -6020
  388. @Label 92
  389.   exit -6022
  390. @Label 93
  391.   exit -6021
  392. @Label 94
  393.   exit -6023
  394. !
  395. ! Processing the AT command:
  396. ! OK -> proceed
  397. ! ERROR or TimeOut ->exit -6019
  398. ! It can be called AFTER the "Write" command, since LineShare buffers input
  399. !
  400. @Label 100
  401.   MatchClr
  402.   MatchStr 1 103 "¥r¥nOK¥r¥n"
  403.   MatchStr 2 102 "¥r¥nERROR¥r¥n"
  404. @Label 101
  405.   MatchRead 20
  406. @Label 102
  407.   Exit -6019
  408. @Label 103
  409.   return
  410.  
  411. @Label 110
  412.   MatchClr
  413.   MatchStr 1 103 "0¥r"
  414.   MatchStr 2 102 "4¥r"
  415.   Jump 101
  416.